﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ObviousCode.Aspect.PluginLibrary.Interfaces;
using ZooKeeperSample.Interfaces;
using ObviousCode.Common.Utils.Library.Dictionaries;
using System.ComponentModel;

namespace ZooKeeperSample.AnimalRegister.Cages
{
    public class Cage : IPropertiesHost, IAspectItem
    {
        PropertyDictionary _properties;
                
        public Cage()
        {
            _properties = new PropertyDictionary();

            Id = Guid.NewGuid().ToString();
            Name = "New Cage";
        }

        public static Cage CreateNew(params object[] args)
        {
            return new Cage();
        }        

        public string Name
        {
            get { return _properties.StringFor("name"); }
            set
            {
                _properties.Set("name", value);

                NotifyPropertyChange("Name");
            }
        }

        [Browsable(false)]
        public string Id
        {
            get { return _properties.StringFor("id"); }
         
            private set { _properties.Set("id", value); }
        }

        [Browsable(false)]
        public ObviousCode.Common.Utils.Library.Dictionaries.PropertyDictionary Properties
        {
            get { return _properties; }
            set { _properties = value; }
        }        

        #region INotifyPropertyChanged Members

        public void NotifyPropertyChange(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        #endregion
        
        
    }
}
